package com.sky.controller.admin;

import com.sky.dto.MessagePageQueryDTO;
import com.sky.dto.ReplyDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.MessageService;
import com.sky.vo.MessageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/message")
public class AdminMessageController {

    @Autowired
    private MessageService messageService;

    @GetMapping("/page")
    public Result<PageResult> pageQuery(MessagePageQueryDTO dto) {
        return Result.success(messageService.pageQuery(dto));
    }

    @PutMapping("/reply")
    public Result reply(@RequestBody ReplyDTO replyDTO) {
        messageService.replyMessage(replyDTO);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result<MessageVO> getById(@PathVariable Long id) {
        return Result.success(messageService.getById(id));
    }
}